<?php require_once(dirname(__FILE__).'/../include/config.inc.php');
require_once "function.php";
/*
进度：
0 已经撤单
1 报修成功
2 客服已经联系
3 系统已经派单
4 工程师接单
5 维修完成
6 已经评价
*/
$orderid= empty($orderid) ? '' : htmlspecialchars($orderid); //进度状态



?>
<!DOCTYPE html>
<html>
<head>
<title>博教通 运维管理系统</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="description" content="修总管运维管理系统">
<link rel="stylesheet" href="lib/weui.min.css">
<link rel="stylesheet" href="css/jquery-weui.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/demos.css">
</head>

<body ontouchstart>
<div class="top"> <img src="images/top.jpg" width="100%"> </div>

<!--工单列表开始-->
<?php
				if(!empty($orderid)){

				$row=$dosql->GetOne("SELECT * FROM `#@__order` WHERE uid='$uid' AND id='$orderid'  AND is_delete=0  " );
				if(!is_array($row)  ){
					exit("工单不存在或者被删除");
				}
					/*
					进度：
					0 已经撤单
					1 报修成功
					2 客服已经联系
					3 系统已经派单
					4 工程师接单
					5 维修完成
					6 已经评价
					*/
					$orderid=$row['id'];
					$jindu2=intval($row['jindu']);
					$apply_type=$row['apply_type'];
					$apply_device=$row['apply_device'];
					
					
					

					//故障图片
					$pic_lists="";
					$previewImage_url=array();
					$picurl_arr=explode(',',$row['picfiles']);
					array_pop($picurl_arr);
					for($i=0;$i<count($picurl_arr);$i++){
						$pic_lists.='<li class="weui-uploader__file" style="background-image:url('.$picurl_arr[$i].')"><img src="'.$picurl_arr[$i].'" width="0"/></li>';
					}
					
					//完修 图片
					$over_picurls=$row['over_picurls'];
					$over_remark=$row['over_remark'];
					$fee=$row['fee'];
					
					// 评价
					$pingjia_start="";
					$pingjia_remark="";
					$start_str="";
					if($jindu2==6){
						$p=$dosql->GetOne("SELECT * FROM `#@__order_evaluate` WHERE orderid='$orderid' ");
						if(is_array($p) && isset($p['id']) ){
							$pingjia_start=$p['start'];
							$pingjia_remark=$p['remark'];
							for($i=0;$i<$pingjia_start;$i++){
								$start_str.='<img src="images/x2.png">';
							}
						}
					}
					
					
					
					
					$op_str="";
					if($jindu2==1){
						$op_str='
        <div class="weui-flex__item"><div class="placeholder"><a class="weui-btn weui-btn_primary" href="javascript:" onClick="chedan('.$row['id'].')"><i class="fa fa-times" aria-hidden="true"></i>取消</a></div></div>
		<div class="weui-flex__item"><div class="placeholder"><a class="weui-btn weui-btn_warn"  href="javascript:" onClick="cuidan('.$row['id'].')"><i class="fa fa-thumb-tack" aria-hidden="true"></i>催单</a></div></div>';
					}elseif($jindu2==5){
						$op_str='
         <div class="weui-flex__item"><div class="placeholder"><a class="weui-btn weui-btn_primary" href="pingjia.php?orderid='.$row['id'].' "><i class="fa fa-thumb-tack" aria-hidden="true"></i>评价</a></div></div>';	
					}
					

				?>

<!--工单详情开始--> 
<!--工单详情开始-->
<div class="main">
  <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>工单信息</div>
  <div class="weui-form-preview">
    <div class="weui-form-preview__bd">
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">工单号：</label>
        <span class="weui-form-preview__value">
        <?php 
		if(!empty($row['poster'])) { 
		echo '<i class="fa fa-smile-o blue "></i>';
		}
		if(!empty($row['openid'])) { 
		echo '<i class="fa fa-weixin green"></i>';
		}		
		?>
        <?php echo date("Ymd",$row['post_time'])."-".$row['id']?> </span> </div>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">单位：</label>
        <span class="weui-form-preview__value"><?php echo $row['school']?></span> </div>
      <?php if(!empty($row['truename'])){?>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">联系人：</label>
        <span class="weui-form-preview__value"><?php echo $row['truename']?></span> </div>
      <?php }?>
      <?php if(!empty($row['mobile'])){?>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">电话：</label>
        <span class="weui-form-preview__value"><a href="tel:<?php echo $row['mobile']?>"><i class="fa fa-mobile"><?php echo $row['mobile']?></a></i></span> </div>
      <?php }?>
      <?php if(!empty($row['mobile'])){?>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">地址：</label>
        <span class="weui-form-preview__value" id="daohang" data-orderid="<?php echo $row['id']?>"><i class="fa fa-map-marker" ><?php echo $row['address']?></i></span> </div>
      <?php }?>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">服务类型：</label>
        <span class="weui-form-preview__value"><i class="fa  fa-drivers-license-o red"></i> <?php echo getTypeName($row['apply_type'])?></span> </div>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">设备类型：</label>
        <span class="weui-form-preview__value"><i class="fa  fa-print red"></i> <?php echo getDeviceName($row['apply_device'])?></span> </div>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">描述：</label>
        <span class="weui-form-preview__value"><?php echo $row['content']?></span> </div>
      <?php if(!empty($row['manage'])){?>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">执行人：</label>
        <span class="weui-form-preview__value">
        <?php 
			if(!empty($row['manageid'])){
				$m_str=$row['manageid'];
				$m_arr=explode(",",$m_str);
				foreach($m_arr as $key=>$val){
					echo ' <i class="fa  fa-user-o red"></i>      '.getManage($val);
				}
			}
			?>
        </span> </div>
      <?php } ?>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">描述图片</label>
        <div class="weui-uploader">
          <div class="weui-uploader__bd">
            <ul class="weui-uploader__files" id="uploaderFiles">
              <?php echo $pic_lists;?>
            </ul>
          </div>
        </div>
      </div>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label red">服务进度</label>
        <span class="weui-form-preview__value">
        <ul>
          <?php
            $dosql->Execute("SELECT * FROM `#@__order_log` WHERE orderid='$orderid'  ORDER BY id asc");
                while($row2 = $dosql->GetArray())
                {
				if($row2['zhuandan']!=="true" ){	
                ?>
          <li><i class="fa fa-check-circle"><?php echo $row2['op']?></i> <?php echo date("m-d H:i:s",$row2['op_time'])?></li>
          <?php
					}
				}
        ?>
        </ul>
        </span> </div>
      <div class="sub_btn"></div>
    </div>
  </div>
  <div class="weui-flex f14"> <?php echo $op_str?> </div>
</div>
</div>
<!--工单详情结束-->
<?php 
  $dosql->Execute("SELECT * FROM `#@__order_log` WHERE orderid='$orderid' AND fankui=true  ORDER BY id asc");
   while($row_f = $dosql->GetArray())
	  {
   ?>
<div class="main">
  <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>反馈信息</div>
  <div class="weui-form-preview">
    <div class="weui-form-preview__bd">
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label"> 反馈内容：</label>
        <span class="weui-form-preview__value"><?php echo $row_f['remark'];?></span> </div>
      <?php if(!empty($row_f['picurl'])){?>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">反馈图片：</label>
        <div class="weui-uploader">
          <div class="weui-uploader__bd">
            <ul class="weui-uploader__files" id="uploaderFiles_over">
              <?php 
					//故障图片
					$pic_lists_f="";
					$previewImage_url_f=array();
					$picurl_arr_f=explode(',',$row_f['picurls']);
					array_pop($picurl_arr_f);
					for($i=0;$i<count($picurl_arr_f);$i++){
						$pic_lists_f.='<li class="weui-uploader__file" style="background-image:url('.$picurl_arr_f[$i].')"><img src="'.$picurl_arr_f[$i].'" width="0"/></li>';
					}
					echo  $pic_lists_f;
			  
			  ?>
            </ul>
          </div>
        </div>
      </div>
      <?php }?>
    </div>
  </div>
</div>
<?php 
  }
  ?>
<?php if($jindu2==6){?>
<div class="main">
  <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>评价信息</div>
  <div class="weui-form-preview">
    <div class="weui-form-preview__bd">
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">服务评价：</label>
        <span class="weui-form-preview__value"><?php echo $start_str.$pingjia_start?>星</span> </div>
      <div class="weui-form-preview__item">
        <label class="weui-form-preview__label">评价内容：</label>
        <span class="weui-form-preview__value"><?php echo $pingjia_remark?></span> </div>
    </div>
  </div>
</div>
<?php }?>
<?php 
  }?>

<!--工单列表结束-->

<div class="clear"></div>
<div class="sub_btn"></div>
<script src="lib/jquery-2.1.4.js"></script> 
<script src="lib/fastclick.js"></script> 
<script>
  $(function() {
    FastClick.attach(document.body);
  });
  
  
  
  function cuidan(id){
	  $.ajax({
		  type: 'POST',
		  url: "op.php",
		  data: {id:id,op:'cui'},
		  dataType: 'JSON',
		  success:function(result){
		  console.log(result);
			if(result.errno==0){
				 console.log(result.msg);
				if(result.msg==="ok"){
					$.toast("催单成功", function() {
					 console.log('close');
					});
					
				}else{
					 $.alert("小主，请耐心等待<br/> 30分钟后可以催单哦！", "温馨提示");
				}
			}
		  }
	  });
	  
  }
  function chedan(id){
	  $.ajax({
		  type: 'POST',
		  url: "op.php",
		  data: {id:id,op:'che'},
		  dataType: 'JSON',
		  success:function(result){
		  console.log(result);
			if(result.errno==0){
				 console.log(result.msg);
				if(result.msg==="ok"){
					$.toast("取消工单成功", function() {
					 window.location.reload();
					});
					
				}else{
					 $.alert("小主，你的工单已经在处理中...<br/> 不能取消工单哦！", "温馨提示");
				}
			}
		  }
	  });
	  
  }
  
</script> 
<script src="js/jquery-weui.js"></script>
<?php require_once('footer.php'); ?>